package com.hy.erp.inventory.service;

import java.util.List ;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

/*import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;
*/
import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.EducationDao;
import com.hy.erp.inventory.dao.interfaces.IContactDao;
import com.hy.erp.inventory.dao.interfaces.IEducationDao;
import com.hy.erp.inventory.pojo.Education;
import com.hy.erp.inventory.pojo.interfaces.IContact;
import com.hy.erp.inventory.pojo.interfaces.IEducation;
import com.hy.erp.inventory.service.interfaces.IEducationService;

/**
 * 
 * <ul>
 * <li>开发作者：李冰</li>
 * <li>设计日期：2010-10-12；时间：下午04:51:50</li>
 * <li>类型名称：EducationService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
/*@ Name ( "educationService" )
@ Scope ( ScopeType.STATELESS )
@ Stateless
*/
@Component("educationService")
public class EducationService extends AbstractBusinessService < EducationDao > implements IEducationService
{

	
	private IEducationDao educationDao=null;
	
	@Resource(name="educationDao")
	public void setPositionTypeDao(IEducationDao educationDao) {
		this.educationDao = educationDao;
	}
	
	@ Override
	public String[] addEducation (
									Object[] education )
	{

		if ( null == education)
		{
			return null ;
		}
		
		else
		{
			

			//IEducationDao educationDao =
			//                       ( IEducationDao ) this
			//                                          .getDao ( IEducation.class ) ;

			Education[] educations=new Education[education.length];
						for(int i=0;i<education.length;i++)
						{
							Education education2=( Education ) education[i];
							educations[i]=education2;
						}
						return educationDao
						                .persist ( educations ) ;
		
		}
		
	
	
	
	
	
	
	}

	@ Override
	public boolean modifyEducation (
										Education education )
	{






		if ( ( null == education )
			     || ( null == education
			                                .getIdentifier ( ) )
			     || ( education
			                        .getIdentifier ( )
			                        .trim ( )
			                        .length ( ) == 0 ) )
			{
				return true ;
			}
			else
			{

			//	IEducationDao educationDao =
           //         ( IEducationDao ) this
            //                           .getDao ( IEducation.class ) ;
	                                        
		
					
				if ( null == education )
				{
					throw new ArchitectureFoundationException  (
					                                            "修改实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
				}
				
				
				return (educationDao
				                  .merge ( education ) != null ) ;
			}
		
	
	
	
	
	
	
	}

	@ Override
	public Integer removeEducation (
										String [ ] educationIds )
	{






		if ( ( null == educationIds)
			     || ( educationIds.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{



			//	IEducationDao educationDao =
           //         ( IEducationDao ) this
             //                          .getDao ( IEducation.class ) ;
	                                        
		

				return educationDao
				                .remove ( educationIds ) ;
			}
	
	
	
	
	
	
	}

	@ SuppressWarnings ( "unused" )
	@ Override
	public List < Education > getEducationById (
													String [ ] Id )
	{
		if((Id.length!=0)||(Id!=null))
		{
		//	IEducationDao educationDao =
        //        ( IEducationDao ) this
       //                            .getDao ( IEducation.class ) ;
			return educationDao.findByIdentifier ( Id );
		}
		return null ;
	}

	@ Override
	public List < Education > getAllEducation ( )
	{

	//	IEducationDao educationDao =
       //     ( IEducationDao ) this
        //                       .getDao ( IEducation.class ) ;
                                    


		return educationDao
		                .find ( );
	}
	
	@ Override
	public List < Education > getEducationByQueryName (
													String queryName ,
													Object[] args )
	{
	//	IEducationDao educationDao =
        //    ( IEducationDao ) this
      //                         .getDao ( IEducation.class ) ;
		return educationDao.findByNamedQuery ( queryName , args ) ;
	}

	@ Override
	public String [ ] modifyEducation (
										Object [ ] education )
	{


		if ( null == education)
		{
			return null ;
		}
		
		else
		{
			

		//	IEducationDao educationDao =
		//	                       ( IEducationDao ) this
		///	                                          .getDao ( IEducation.class ) ;

			Education[] educations=new Education[education.length];
						for(int i=0;i<education.length;i++)
						{
							Education education2=( Education ) education[i];
							educations[i]=education2;
						}
						return educationDao
						                .merge   ( educations ) ;
		
		}
		
	
	
	
	
	
	
	
	}

}
